﻿using Autofac;
using Common.Interface;
using EntityFrameworkExtension;
using EntityFrameworkExtension.Caching;
using EntityFrameworkExtension.Interface;
using MainProcessor.Caching;
using MainProcessor.ContextProcessor;
using MainProcessor.Interface;
using MainProcessor.MessageProcessor;
using MainProcessor.Processors;
using MainProcessor.Validation;


namespace MainProcessor
{
    public static class IoC
    {
        public static void Initialize()
        {
            var builder = new ContainerBuilder();


            builder.RegisterType<ReplacedInteface1Processor>().As<IContextProcessor>();
            builder.RegisterType<ReplacedInteface2Processor>().As<IContextProcessor>();
            
            builder.RegisterType<DataCache>().As<IDataCache>().SingleInstance();
            builder.RegisterType<EfEntities>().As<IEfContext>().InstancePerDependency();
            builder.RegisterType<EntityFactory>().As<IEntityFactory>().InstancePerDependency();
            builder.RegisterType<DataController>().As<IDataController>().InstancePerDependency();

            builder.RegisterType<RepositoryFlush>().As<IRepositoryFlush>().InstancePerDependency();

            builder.RegisterType<ReportingFilterProcessor>().As<IReportingFilter>().InstancePerDependency();
            builder.RegisterType<LatestParentMeasuresProcessor>().As<ILatestParentMeasures>().InstancePerDependency();

            builder.RegisterType<ChildValidation>().As<IValidateInput>();


            Container = builder.Build();
        }

        public static IContainer Container { get; private set; }
    }
    
}
